//
//  LoginModel.m
//  MobileOffice
//
//  Created by Appel on 16/10/13.
//  Copyright © 2016年 liaoningjujin. All rights reserved.
//

#import "LoginModel.h"

@implementation LoginModel

//编码
-(void)encodeWithCoder:(NSCoder *)aCoder
{
    //将每个属性都进行编码
    [aCoder encodeObject:self.loginName forKey:LOGIN_USERNAME];
    [aCoder encodeObject:self.passWord forKey:LOGIN_PASSWORD];
    [aCoder encodeObject:self.registrationID forKey:REGISTRATIONID];
    [aCoder encodeObject:self.power forKey:LOGIN_USERPOWER];
    [aCoder encodeObject:self.PersonName forKey:LOGIN_PERSONNAME];
    [aCoder encodeObject:self.PersonID forKey:LOGIN_SESSIONID];
    [aCoder encodeObject:@(self.isAutoLogin) forKey:ISAUTOLOGIN];
    [aCoder encodeObject:@(self.isRemeberPwd) forKey:ISREMEBERPWD];
}
//解码
-(id)initWithCoder:(NSCoder *)aDecoder
{
    if (self=[super init]) {
        
        //获得解码的内容
        self.loginName=[aDecoder decodeObjectForKey:LOGIN_USERNAME];
        self.passWord=[aDecoder decodeObjectForKey:LOGIN_PASSWORD];
        self.registrationID = [aDecoder decodeObjectForKey:REGISTRATIONID];
        self.power = [aDecoder decodeObjectForKey:LOGIN_USERPOWER];
        self.PersonName = [aDecoder decodeObjectForKey:LOGIN_PERSONNAME];
        self.PersonID = [aDecoder decodeObjectForKey:LOGIN_SESSIONID];
        self.isAutoLogin = [[aDecoder decodeObjectForKey:ISAUTOLOGIN] boolValue];
        self.isRemeberPwd = [[aDecoder decodeObjectForKey:ISREMEBERPWD] boolValue];
    }
    return self;
}
//为自己开辟一块空的空间，进行占位
-(id)copyWithZone:(NSZone *)zone
{
    LoginModel *person=[[self class]allocWithZone:zone];
    person.loginName=[self.loginName copyWithZone:zone];
    person.passWord=[self.passWord copyWithZone:zone];
    person.registrationID = [self.registrationID copyWithZone:zone];
    person.power = [self.power copyWithZone:zone];
    person.PersonName = [self.PersonName copyWithZone:zone];
    person.PersonID = [self.PersonID copyWithZone:zone];
    person.isAutoLogin = [[@(self.isAutoLogin) copyWithZone:zone] boolValue];
    person.isRemeberPwd = [[@(self.isRemeberPwd) copyWithZone:zone] boolValue];
    return person;
}

@end
